
import { _decorator, Component, director, Node, instantiate, Prefab, Collider, MeshRenderer } from 'cc';
import Utils from '../../../core/utils/Utils';
import PoolMgr from '../../../core/manager/PoolMgr';
import Data from '../../../core/manager/Data';
import BusyLoadingManager from '../../../core/manager/BusyLoadingManager';
import WXTTUtils from '../../../core/manager/WXTTUtils';
const { ccclass, property } = _decorator;

const wx = window['wx']
@ccclass('Loading')
export class Loading extends Component {
    start() {
        // console.log = () => { };
        // console.warn = () => { };
        if (window['wx']) {
            window['wx'].showShareMenu({
                withShareTicket: true,
                menus: ['shareAppMessage', 'shareTimeline']
            })
        }

        // WXTTUtils.initGridAd();
        //    setDisplayStats(true);
        //    game.setFrameRate(60);
        if (wx) {
            wx.setPreferredFramesPerSecond(60);
            wx.setKeepScreenOn({ keepScreenOn: true });
        }
        this.subpackagecomplete();
    }

    async subpackagecomplete() {
        Data.loadData();
        await Utils.loadBundler("item0");
        await Utils.loadBundler("prefabs");
        await Utils.loadBundler("spine");
        await Utils.loadBundler("sounds");
        if (Data.user.lv == 1) {
            Utils.loadBundler("item1");
        }
        else {
            await Utils.loadBundler("item1");
        }
        await PoolMgr.Instance().loadPrefabs();
        BusyLoadingManager.ins;
        // WXTTUtils.initVideo()
        // WXTTUtils.initInterstitialAd()
        director.loadScene("main")
    }
}

